import cors from '@koa/cors';
import { bodyParser } from '@koa/bodyparser';
import Koa from 'koa';
import userRouter from './router/user.js';
import teacherRouter from './router/teacher.js';

const app = new Koa();


app.use(cors());
app.use(bodyParser()); // 辅助koa解析post传递的参数 ，放在路由生效之前
app.use(userRouter.routes(), userRouter.allowedMethods());
app.use(teacherRouter.routes(), teacherRouter.allowedMethods());


app.listen(3000, () => {
    console.log('server is running at http://localhost:3000');
});